package com.example.parser;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
@Component
public class RemoteOriginParser implements RequestOriginParser {
    @Override
    public String parseOrigin(HttpServletRequest httpServletRequest) {
        String fromsource = httpServletRequest.getHeader("fromsource");
        if (fromsource == null || "".equals(fromsource)){
            fromsource = "error";
        }
        return fromsource;
    }
}
